package com.tencent.matrix.trace.g;

public class Trace_G_B {
    public static String getStack() {
        return a(new Throwable().getStackTrace());
    }

    public static String a(StackTraceElement[] stackTraceElementArr) {
        return a(stackTraceElementArr, "", -1);
    }

    public static String a(StackTraceElement[] stackTraceElementArr, String str, int i) {
        int i2 = 3;
        if (stackTraceElementArr == null || stackTraceElementArr.length < 3) {
            return "";
        }
        if (i < 0) {
            i = Integer.MAX_VALUE;
        }
        StringBuilder stringBuilder = new StringBuilder(" \n");
        while (i2 < stackTraceElementArr.length - 3 && i2 < i) {
            stringBuilder.append(str);
            stringBuilder.append("at ");
            stringBuilder.append(stackTraceElementArr[i2].getClassName());
            stringBuilder.append(":");
            stringBuilder.append(stackTraceElementArr[i2].getMethodName());
            stringBuilder.append("(");
            stringBuilder.append(stackTraceElementArr[i2].getLineNumber());
            stringBuilder.append(")");
            stringBuilder.append("\n");
            i2++;
        }
        return stringBuilder.toString();
    }
}
